import React from "react";
import Loadable from "react-loadable";
import { Spin } from "antd";

//通用的过场组件
const loadingComponent = () => {
  return (
    <div
      style={{
        display: "flex",
        justifyContent: "center",
        alignItems: "center",
        height: "100vh",
      }}
    >
      <Spin tip="正在拼命的加载中..." spinning={true} />
    </div>
  );
};

//过场组件默认采用通用的，若传入了loading，则采用传入的过场组件
export default (loader, loading = loadingComponent) => {
  return Loadable({
    loader,
    loading,
  });
};
